#!/bin/bash
#
#	/etc/rc.d/init.d/siproxd
#
# Starts the siproxd daemon
#
# chkconfig: 345 94 80
#
# description: Listen and dispatch SIP messages 
# processname: siproxd 

# Source function library.
. /etc/rc.d/init.d/functions

[ -x /usr/sbin/siproxd ] || exit 0

RETVAL=0

#
# See how we were called.
#

start() {
	# Check if it is already running
	if [ ! -f /var/lock/subsys/siproxd ]; then
	    echo -n $"Starting sip proxy: "
	    daemon /usr/sbin/siproxd
	    RETVAL=$?
	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/siproxd
	    echo
	fi
	return $RETVAL
}

stop() {
	echo -n $"Stopping sip proxy: "
	killproc /usr/sbin/siproxd
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/siproxd
	echo
        return $RETVAL
}


restart() {
	stop
	start
}	

reload() {
	trap "" SIGHUP
	killall -HUP siproxd
}	

case "$1" in
start)
	start
	;;
stop)
	stop
	;;
reload)
	reload
	;;
restart)
	restart
	;;
condrestart)
	if [ -f /var/lock/subsys/siproxd ]; then
	    restart
	fi
	;;
status)
	status siproxd
	;;
*)
	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
	exit 1
esac

exit $RETVAL
